<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>向服务器池中增加多台服务器</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="memcached.addserver.html">« Memcached::addServer</a></li>
      <li style="float: right;"><a href="memcached.append.html">Memcached::append »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.memcached.html">Memcached</a></li>
    <li>向服务器池中增加多台服务器</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="memcached.addservers" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Memcached::addServers</h1>
  <p class="verinfo">(PECL memcached &gt;= 0.1.1)</p><p class="refpurpose"><span class="refname">Memcached::addServers</span> &mdash; <span class="dc-title">向服务器池中增加多台服务器</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-memcached.addservers-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Memcached::addServers</strong></span>(<span class="methodparam"><span class="type">array</span> <code class="parameter">$servers</code></span>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>Memcached::addServers()</strong></span>向服务器池中增加<code class="parameter">servers</code>参数指定的服务器。
   <code class="parameter">servers</code>中的每一条都是一个包含主机名，端口以及可选的权重等服务器参数。此时并不会与这些服务端建立
   连接。
  </p>
  <p class="para">
  同一台服务器可以在服务器池中多次出现，因为这里没有做重复检测。但这是不推荐的做法，对于期望提高某台服务器
  权重的需求，请使用<code class="parameter">weight</code>参数。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-memcached.addservers-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">array</code></dt>

     <dd>

      <p class="para">
      将要增加到池中的服务器列表数组。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-memcached.addservers-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>true</code></strong>， 或者在失败时返回 <strong><code>false</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-memcached.addservers-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4381">
    <p><strong>示例 #1 <span class="function"><strong>Memcached::addServers()</strong></span>示例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$m&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Memcached</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$servers&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;array(</span><span style="color: #DD0000">'mem1.domain.com'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">11211</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">33</span><span style="color: #007700">),<br />&nbsp;&nbsp;&nbsp;&nbsp;array(</span><span style="color: #DD0000">'mem2.domain.com'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">11211</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">67</span><span style="color: #007700">)<br />);<br /></span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addServers</span><span style="color: #007700">(</span><span style="color: #0000BB">$servers</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-memcached.addservers-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="memcached.addserver.html" class="methodname" rel="rdfs-seeAlso">Memcached::addServer()</a> - 向服务器池中增加一个服务器</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>